home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Portable Patmos 1.1 / patmos-src / src / utimes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-19  |  1.1 KB  |  37 lines  |  [TEXT/KAHL]

  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <errno.h>
  5. #include "crtlocal.h"
  6.  
  7. #define macTime(t) (t + (time_t)0x7c25b080)
  8.  
  9. int utimes(const char *name, const struct timeval *buf)
  10.         {
  11.         CInfoPBRec  cPB;
  12.         FSSpec canon = hfs_canon(crt_parID, name, 1);
  13.         if (!*canon.name) return -1;
  14.         cPB.hFileInfo.ioNamePtr = canon.name;
  15.         cPB.hFileInfo.ioVRefNum = canon.vRefNum;
  16.         cPB.hFileInfo.ioDirID = canon.parID;
  17.         cPB.hFileInfo.ioFDirIndex = 0;
  18.         if (PBGetCatInfoSync(&cPB))
  19.             {
  20.             errtran(cPB.hFileInfo.ioResult);
  21.             return -1;
  22.             }
  23.         /* last access time, modification time and creation time(?) */
  24.         cPB.hFileInfo.ioFlMdDat = macTime(buf->tv_sec);
  25.         cPB.hFileInfo.ioFlCrDat = macTime(buf->tv_sec);
  26.         cPB.hFileInfo.ioNamePtr = canon.name;
  27.         cPB.hFileInfo.ioVRefNum = canon.vRefNum;
  28.         cPB.hFileInfo.ioDirID = canon.parID;
  29.         cPB.hFileInfo.ioFDirIndex = 0;
  30.         if (PBSetCatInfoSync(&cPB))
  31.             {
  32.             errtran(cPB.hFileInfo.ioResult);
  33.             return -1;
  34.             }
  35.         return 0;
  36.         }
  37.